#!/bin/bash

if [ ! "${JVM_MINIMUM_MEMORY}" = '' ] && [ ! "${JVM_MAXIMUM_MEMORY}" = '' ]; then
    cp -f ${ATLASSIAN_INSTALL_DIR}/conf/setenv.sh ${ATLASSIAN_INSTALL_DIR}/crowd/apache-tomcat/bin/
fi

if [ "$PROXY_ENABLED" = 'true' ]; then
    cp -f ${ATLASSIAN_INSTALL_DIR}/conf/server-with-proxy.xml ${ATLASSIAN_INSTALL_DIR}/crowd/apache-tomcat/conf/server.xml
    sed -i "s/\${PROXY_SCHEME}/${PROXY_SCHEME}/g" ${ATLASSIAN_INSTALL_DIR}/crowd/apache-tomcat/conf/server.xml
    sed -i "s/\${PROXY_NAME}/${PROXY_NAME}/g" ${ATLASSIAN_INSTALL_DIR}/crowd/apache-tomcat/conf/server.xml
    sed -i "s/\${PROXY_PORT}/${PROXY_PORT}/g" ${ATLASSIAN_INSTALL_DIR}/crowd/apache-tomcat/conf/server.xml
fi
